<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Priithon.readerSPE</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="Priithon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/priithon">Priithon</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="Priithon-module.html">Package&nbsp;Priithon</a> ::
        Module&nbsp;readerSPE
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="Priithon.readerSPE-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module readerSPE</h1><p class="nomargin-top"><span class="codelink"><a href="Priithon.readerSPE-pysrc.html">source&nbsp;code</a></span></p>
<p>Priithon: reader for Hamamatsu(?) SPE files</p>
  <p># http://www.scipy.org/Cookbook/Reading_SPE_files # 
  http://forums.wolfram.com/student-support/topics/8778</p>
  <p># MORE INFO AT 
  http://ftp.roperscientific.com/Public/Manuals/Princeton%20Instruments/ #
  WinSpec32.pdf</p>

<hr />
<div class="fields">      <p><strong>Author:</strong>
        Sebastian Haase &lt;seb.haase+Priithon@gmail.com&gt;
      </p>
      <p><strong>License:</strong>
        BSD license - see LICENSE file
      </p>
</div><!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Classes</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Classes"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="Priithon.readerSPE.File-class.html" class="summary-name">File</a>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="load"></a><span class="summary-sig-name">load</span>(<span class="summary-sig-arg">fname</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.readerSPE-pysrc.html#load">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.readerSPE-module.html#speToFits" class="summary-sig-name">speToFits</a>(<span class="summary-sig-arg">spefile</span>,
        <span class="summary-sig-arg">fitsfile</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">clobber</span>=<span class="summary-sig-default">False</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Read in an SPE file and output a FITS file</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.readerSPE-pysrc.html#speToFits">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.readerSPE-module.html#readSpe" class="summary-sig-name">readSpe</a>(<span class="summary-sig-arg">spefilename</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>,
        <span class="summary-sig-arg">onlyHdr</span>=<span class="summary-sig-default">False</span>)</span><br />
      Read a binary PI SPE file into a python dictionary</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.readerSPE-pysrc.html#readSpe">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.readerSPE-module.html#speDictToFits" class="summary-sig-name">speDictToFits</a>(<span class="summary-sig-arg">spedict</span>,
        <span class="summary-sig-arg">outfile</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">clobber</span>=<span class="summary-sig-default">False</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Given a python dictionary containing information about the SPE file 
      generate a sequence of FITS files, one FITS file per image in the SPE
      file.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.readerSPE-pysrc.html#speDictToFits">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="Priithon.readerSPE-module.html#_getHeaderDescriptions" class="summary-sig-name" onclick="show_private();">_getHeaderDescriptions</a>()</span><br />
      Defines the descriptions of the Header items that are populated in 
      readSpe().</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="Priithon.readerSPE-pysrc.html#_getHeaderDescriptions">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="Priithon.readerSPE-module.html#_header_struct__info" class="summary-name" onclick="show_private();">_header_struct__info</a> = <code title="''' 
typedef struct tagCSMAHEAD {
#ifdef __cplusplus                // STARTING
  tagCSMAHEAD();                  // ADDRESS
#endif                            // (decimal)
  SHORT   ControllerVersion;      //    0  Hardware Version
  SHORT   LogicOutput;            //    2  Definition of Output BNC
  WORD    AmpHiCapLowNoise;       //    4  Amp Switching Mode
..."><code class="variable-quote">'</code><code class="variable-string"> \ntypedef struct tagCSMAHEAD {\n#ifde</code><code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="Priithon.readerSPE-module.html#_type_dtype_map" class="summary-name" onclick="show_private();">_type_dtype_map</a> = <code title="{0: &lt;type 'numpy.float32'&gt;,
 1: &lt;type 'numpy.int32'&gt;,
 2: &lt;type 'numpy.int16'&gt;,
 3: &lt;type 'numpy.uint16'&gt;}"><code class="variable-group">{</code>0<code class="variable-op">: </code>&lt;type 'numpy.float32'&gt;<code class="variable-op">, </code>1<code class="variable-op">: </code>&lt;type 'numpy.<code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="speToFits"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">speToFits</span>(<span class="sig-arg">spefile</span>,
        <span class="sig-arg">fitsfile</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">clobber</span>=<span class="sig-default">False</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.readerSPE-pysrc.html#speToFits">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Read in an SPE file and output a FITS file</p>
  <p>Example usage: Given an SPE file named test.SPE which contains 3 image
  frames, then the following code will produce three FITS images, named: .
  image_x001.fits .   image_x002.fits .   image_x003.fits &gt;&gt;&gt; 
  import piUtils &gt;&gt;&gt; piUtils.speToFits('test.SPE', 
  fitsfile='image')</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="readSpe"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">readSpe</span>(<span class="sig-arg">spefilename</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>,
        <span class="sig-arg">onlyHdr</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.readerSPE-pysrc.html#readSpe">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Read a binary PI SPE file into a python dictionary

Inputs
spefilename --  string specifying the name of the SPE file to be read
verbose     --  boolean print debug statements (True) or not (False)
onlyHdr     --  if True, only read header, and skip filling `data` with image data

Outputs
spedict     --  python dictionary containing header and data information
                from the SPE file
                Content of the dictionary is:
                spedict = {'data':[],    # a list of 2D numpy arrays, one per image
                'IGAIN':pimaxGain,
                'EXPOSURE':exp_sec,
                'SPEFNAME':spefilename,
                'OBSDATE':date,
                'CHIPTEMP':detectorTemperature
           }

Example usage:
Given an SPE file named test.SPE, you can read the SPE data into
a python dictionary named spedict with the following:
&gt;&gt;&gt; import piUtils
&gt;&gt;&gt; spedict = piUtils.readSpe('test.SPE')

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="speDictToFits"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">speDictToFits</span>(<span class="sig-arg">spedict</span>,
        <span class="sig-arg">outfile</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">clobber</span>=<span class="sig-default">False</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.readerSPE-pysrc.html#speDictToFits">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Given a python dictionary containing information about the SPE file 
  generate a sequence of FITS files, one FITS file per image in the SPE 
  file.</p>
  <p>Inputs spedict  --   A dictionary containing information from the SPE 
  file .             as output by readSpe() outfile  --   root of output 
  filename for FITS files. .             e.g. outfile='fitsimage'  will 
  produce fits files .             named fitsimage_x000.fits clobber  --   
  Boolean.  True will overwrite any existing FITS files. verbose  --   
  Print debug messages.</p>
  <p>Outputs fitsFileNames  --  Returns a list of the generated output 
  filenames.</p>
  <p>Example usage: If the file called test.SPE contains 3 image frames, 
  then the following code: &gt;&gt;&gt; import piUtils &gt;&gt;&gt; spedict
  = piUtils.readSpe('test.SPE') &gt;&gt;&gt; piUtils.speDictToFits(spedict,
  outfile='image') will produce three FITS images, named: .   
  image_x001.fits .   image_x002.fits .   image_x003.fits</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="_getHeaderDescriptions"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_getHeaderDescriptions</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="Priithon.readerSPE-pysrc.html#_getHeaderDescriptions">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Defines the descriptions of the Header items that are populated in 
  readSpe().  Only a few quantities (see below) are transferred from the 
  SPE header into the FITS header.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-VariablesDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="_header_struct__info"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">_header_struct__info</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-quote">'''</code><code class="variable-string"> </code>
<code class="variable-string">typedef struct tagCSMAHEAD {</code>
<code class="variable-string">#ifdef __cplusplus                // STARTING</code>
<code class="variable-string">  tagCSMAHEAD();                  // ADDRESS</code>
<code class="variable-string">#endif                            // (decimal)</code>
<code class="variable-string">  SHORT   ControllerVersion;      //    0  Hardware Version</code>
<code class="variable-string">  SHORT   LogicOutput;            //    2  Definition of Output BNC</code>
<code class="variable-string">  WORD    AmpHiCapLowNoise;       //    4  Amp Switching Mode</code>
<code class="variable-ellipsis">...</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="_type_dtype_map"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">_type_dtype_map</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">{</code>0<code class="variable-op">: </code>&lt;type 'numpy.float32'&gt;<code class="variable-op">,</code>
 1<code class="variable-op">: </code>&lt;type 'numpy.int32'&gt;<code class="variable-op">,</code>
 2<code class="variable-op">: </code>&lt;type 'numpy.int16'&gt;<code class="variable-op">,</code>
 3<code class="variable-op">: </code>&lt;type 'numpy.uint16'&gt;<code class="variable-group">}</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="Priithon-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/priithon">Priithon</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Nov 22 14:59:33 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
